<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" scope="request"/>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="<c:url value='/resources/styles/main.css' />" type="text/css"/>
    <script type="text/javascript">
        var contextPath = '${ctx}/';
        function deleteDate(id,cate){

            if(window.confirm("确定要删除吗？"))
            {
                <%--/admin/folder/deleteFolder.do?id=${item.id}&cate=${cate}--%>
                window.location.href=contextPath+'/admin/folder/deleteFolder.do?id='+id+'&cate='+cate;
            }

            <%----%>
        }
    </script>
    <title>文件夹列表</title>
</head>
<body>
<table class="header">
    <tr>
        <td>
            <h1>文件夹列表</h1>

        </td>
    </tr>
</table>
<table class="pagination" style="padding-left: 70px;">
    <tr>
        <td>
            <a href="<c:url value="/admin/folder/addFolder.do" />">新建文件夹</a>
        </td>
        <td>
            <form method="post" action="<c:url value='/admin/folder/listFolder.do'/>" >

                       档案类别： <select id="cate" name="cate">
                <option value='' >--请选择--</option>
                        <option value='0' ${cate=='0'? 'selected':''}>本期亮点</option>
                        <option value='1' ${cate=='1'? 'selected':''}>精彩回顾</option>
                       </select>
                <input type="submit" value="搜索"/>
                </form>


        </td>
    </tr>
</table>

<table class="list">
    <tr>
        <th>序号</th>
        <th>文件夹名称</th>
        <th>显示时期</th>
        <th>创建时间</th>
        <th>删除</th>
    </tr>
    <c:choose>
        <c:when test="${totalCount > 0}">
            <c:forEach var="item" items="${results}">
                <tr>
                        <%--<td><input type="checkbox" class="itemId" value="${item.id}" /></td>--%>

                    <td><a href="<c:url value='/admin/folder/viewFolder.do?id=${item.id}&cate=${cate}'/>">${item.seq}</a></td>

                    <td>
                        <a href="<c:url value='/admin/folder/viewFolder.do?id=${item.id}&cate=${cate}'/>">${item.title}</a>
                    </td>
                    <td>${item.date}</td>
                    <td>
                        <fmt:formatDate value="${item.entryDate}" pattern="yyyy-MM-dd" />
                    </td>
                    <td>
                        <%--<a href="<c:url value='/admin/folder/deleteFolder.do?id=${item.id}&cate=${cate}'/>">删除</a>--%>
                        <a href="#" onclick="deleteDate('${item.id}','${cate}')">删除</a>
                    </td>
                </tr>
            </c:forEach>
        </c:when>
        <c:otherwise>
            <tr>
                <td colspan="17">没有数据</td>
            </tr>
        </c:otherwise>
    </c:choose>

</table>
</body>
</html>